<template>
<!-- 这是报名页面 -->
  <div id="SignUp">
    <div class="Header-wrapper">
    <!-- 头部 -->
    <yd-navbar title="填写简历" bgcolor="#FFD602" color="#fff" height="45px" fontsize="16px">
        <div @click="blanck(positionlist.id)" slot="left">
            <i class="iconfont icon-back Fcolor" ></i>
        </div>
    </yd-navbar>
    </div>
    <!-- 头像个人信息展示 -->
    <div class="information-wrapper">
        <div class="msg-portrait">
            <div class="head-portrait">
                <span class="portrait-box">
                  <img src="../../../../assets/img/1.png" alt="">
                </span>
            </div>
            <div class="information-content">
                <ul>
                    <li>
                        <span>姓名：{{userdata.name}}</span>
                        <span v-if='userdata.sex===2'>女</span>
                        <span v-else-if="userdata.sex===1">男</span>
                        <span v-else></span>
                    </li>
                    <li>手机：{{userdata.phone}}</li>
                    <li>{{userdata.deptname}}</li>
                </ul>
            </div>
        </div>
        <router-link to="/personal/BaseInformation">
            <div class="information-compile">编辑</div>
        </router-link>
    </div>
    <!-- 简历填写页面 -->
    <div class="write-wrapper">
        <div id="resume-box-list">
          <ul>
            <li>
                <group>
                    <cell
                    :arrow-direction="off ? 'up' : 'down'"
                    @click.native="off = !off"
                    >
                    <span v-if="!off" slot="title" class="foldS1">教育经历</span>
                    <span v-else slot="title" class="foldS2">教育经历</span>
                    <i :class="off?' iconfont icon-jianhao':'iconfont icon-add'"></i>
                    </cell>
                    <div class="slide" :class="off?'animate':''">
                    <transition-group appear enter-active-class="animated fadeIn" appear-active-class="animated fadeIn">
                       <div class="slide-center" v-for="(list,index) in itemData" :key='index'>
                           <div class="slide-left">
                            <p >时间：{{list.begindate.split(' ')[0]}}---{{list.enddate.split(' ')[0]}}</p>
                            <p v-if='list.school'>学校：{{list.school}}</p>
                            <p v-if='list.zhuanye'>主修专业：{{list.zhuanye}}</p>
                            <p v-if='list.goodat'>兴趣爱好：{{list.goodat}}</p>
                            <br/>
                           </div>
                           <div class="slide-right">
                                <div class="slidebtn-right" @click='removeschool(list.id)'>删除</div>
                                <div class="slidebtn-right1" @click='toEducationalExperience(list.id)'>编辑</div>
                           </div>
                      </div>
                   </transition-group>
                        <div class="after-fill">
                            <router-link to="personal/EducationalExperience" >
                                <span>+添加</span>
                            </router-link>
                        </div>
                    </div>
                </group>
            </li>
            <li>
                <group>
                    <cell
                    :arrow-direction="off2 ? 'up' : 'down'"
                    @click.native="off2 = !off2"
                    >
                    <span v-if="!off2" slot="title" class="foldS1">应聘优势</span>
                    <span v-else slot="title" class="foldS2">应聘优势</span>
                     <i :class="off2?' iconfont icon-jianhao':'iconfont icon-add'"></i>
                    </cell>
                    <div class="slide" :class="off2?'animate':''">
                    <transition-group appear enter-active-class="animated fadeIn" appear-active-class="animated fadeIn">
                        <div class="slide-center" v-for="(list2,index) in itemData1" :key='index'>
                            <div class="slide-left" v-if='list2'>
                                <p >{{list2.ypys}}</p>
                           </div>
                           <div class="slide-right">
                                <div class="slidebtn-right" v-if='list2.ypys!=""' @click='removeyoushi(list2.id)'>删除</div>
                                <div class="slidebtn-right1" v-if='list2.ypys!=""' @click='toypys(list2.id)'>编辑</div>
                           </div>
                        </div>
                        </transition-group>
                         <div class="after-fill">
                            <router-link to="personal/advantage">
                                <span>+添加</span>
                            </router-link>
                        </div>
                    </div>
                </group>
            </li>
             <li>
                 <group>
                    <cell
                    :arrow-direction="off1 ? 'up' : 'down'"
                    @click.native="off1 = !off1"
                    >
                    <span v-if="!off1" slot="title" class="foldS1">社会实践</span>
                    <span v-else slot="title" class="foldS2">社会实践</span>
                     <i :class="off1?' iconfont icon-jianhao':'iconfont icon-add'"></i>
                    </cell>
                    <div class="slide" :class="off1?'animate':''">
                        <div class="Q-wrapper">
                            <transition-group appear enter-active-class="animated fadeIn" appear-active-class="animated fadeIn">
                            <div class="Q" v-for="(item,index) of itemData2" :key="index">
                                <label>{{index+1}}.{{item.question}}</label>
                                <div class="radio-wrapper">
                                  <span>选择：</span>
                                  <span v-if="item.answer ==='1'">是</span>
                                  <span v-else>否</span>
                                </div>
                            </div>
                            </transition-group>
                             <div class="after-fill">
                                <router-link to="personal/SocialExperience" >
                                    <span>+编辑</span>
                                </router-link>
                            </div>
                        </div>
                    </div>
                </group>
            </li>
          </ul>
      </div>
    </div>
    <!-- 报名按钮 -->
    <div class="positioning-wrapper">
        <div class="submit-wrapper">
            <yd-button type="primary"  @click.native="Signup" v-show="isshow" bgcolor="#F0F0F0" style="margin:0 auto">
                <div class="submit-btn" >
                    报名
                </div>
            </yd-button>
        </div>
    </div>
  </div>
</template>
<script>
import { Group, Cell } from 'vux'
import apis from '../../../../../static/js/apis.js'
export default {
  data () {
    return {
      show: 1,
      userdata: [],
      itemData: [],
      itemData2: [],
      itemData1: [],
      show1: false,
      off: true,
      off1: true,
      off2: true,
      positionlist: {},
      isshow: true,
      type: '',
      qeslist: [],
      jobid: ''
    }
  },
  created () {
    this.jobid = this.$route.query.id
    this.userdata = JSON.parse(window.localStorage.getItem('userInfo')).member
    console.log(this.userdata)
    this.getitemdataAll()
    this.type = this.$route.query.type
    if (this.type === '2') {
      this.isshow = false
    }
  },
  methods: {
    getitemdataAll () {
      this.$axios.post(apis + '/app/school/getresume',
        this.confusion(JSON.stringify({
          userid: this.userdata.id + ''
        })
        ),
        {
          headers: {
            Authorization: 'Bearer ' + JSON.parse(window.localStorage.getItem('userInfo')).token,
            'Content-Type': 'application/json;charset=UTF-8',
            'Cache-Control': 'no-cache',
            isApp: 'isApp'
          }
        }
      )
        .then(response => {
          this.itemData = response.data.school
          this.itemData1 = response.data.ypys
          this.itemData2 = response.data.question
        //   console.log(this.itemData2)
        })
        .catch(error => {
          console.log(error)
          this.$dialog.toast({
            mes: '服务器异常'
          })
        })
    },
    Signup () {
      if ((this.itemData.length <= 0) || (this.itemData2.length <= 0) || (this.itemData1.length <= 0)) {
        this.$dialog.toast({
          mes: '请完善简历'
        })
      } else {
        this.$axios.post(apis + '/app/jobresume/addjobresume',
          this.confusion(JSON.stringify({
            jobid: this.jobid
          })
          ),
          {
            headers: {
              Authorization: 'Bearer ' + JSON.parse(window.localStorage.getItem('userInfo')).token,
              'Content-Type': 'application/json;charset=UTF-8',
              'Cache-Control': 'no-cache',
              isApp: 'isApp'
            }
          }
        )
          .then(response => {
            this.$dialog.toast({
              mes: '报名成功',
              callback: () => {
                this.$router.push({
                  path: '/index'
                })
              }
            })
          })
          .catch(error => {
            console.log(error)
            this.$dialog.toast({
              mes: '服务器异常'
            })
          })
      }
    },
    blanck (id) {
      window.history.go(-1)
    },
    toEducationalExperience (id) {
      this.$router.push({
        path: '/personal/EducationalExperience',
        query: {
          id: id
        }
      })
    },
    toshehuishijian (id) {
      this.$router.push({
        path: '/personal/SocialExperience',
        query: {
          id: id
        }
      })
    },
    toypys (id) {
      this.$router.push({
        path: '/personal/advantage',
        query: {
          id: id
        }
      })
    },
    removeschool (id) {
      this.$axios.post(apis + '/app/school/deleteschool', this.confusion(JSON.stringify({
        id: id + ''
      })
      ),
      {
        headers: {
          Authorization: 'Bearer ' + JSON.parse(window.localStorage.getItem('userInfo')).token,
          'Content-Type': 'application/json;charset=UTF-8',
          'Cache-Control': 'no-cache',
          isApp: 'isApp'
        }
      }
      )
        .then(response => {
          this.getitemdataAll()
        //   console.log(this.itemData)
        })
        .catch(error => {
          console.log(error)
          this.$dialog.toast({
            mes: '服务器异常'
          })
        })
    },
    removeshijian (id) {
      this.$axios.post(apis + '/app/shehuishijian/delete', this.confusion(JSON.stringify({
        id: id + ''
      })
      ),
      {
        headers: {
          Authorization: 'Bearer ' + JSON.parse(window.localStorage.getItem('userInfo')).token,
          'Content-Type': 'application/json;charset=UTF-8',
          'Cache-Control': 'no-cache',
          isApp: 'isApp'
        }
      }
      )
        .then(response => {
          this.getitemdataAll()
        })
        .catch(error => {
          console.log(error)
          this.$dialog.toast({
            mes: '服务器异常'
          })
        })
    },
    removeyoushi (id) {
      this.$axios.post(apis + '/app/ypys/delete', this.confusion(JSON.stringify({
        id: id + ''
      })
      ),
      {
        headers: {
          Authorization: 'Bearer ' + JSON.parse(window.localStorage.getItem('userInfo')).token,
          'Content-Type': 'application/json;charset=UTF-8',
          'Cache-Control': 'no-cache',
          isApp: 'isApp'
        }
      }
      )
        .then(response => {
          this.getitemdataAll()
        //   console.log(this.itemData)
        })
        .catch(error => {
          console.log(error)
          this.$dialog.toast({
            mes: '服务器异常'
          })
        })
    }
  },
  components: {
    Group,
    Cell,
    apis
  }
}
</script>
<style scoped>
.fsize{
    font-size: 70px;
    color: #ffd602;
}
.icon-back{
  font-size: 24px;
}
.Fcolor {
  color: #fff;
}
#SignUp {
    background-color: #fff;
    height: 100%;
    width: 100%;
    position: fixed;
    font-family: PingFangSC-Medium;
    font-size: 12px;
    line-height: 20px;
}
.information-wrapper {
    width: 100%;
    height: 132px;
    padding:24px 12px;
    display: flex;
    justify-content: space-around;
    border-bottom: 4px solid #DFDFDF;
    overflow: hidden;
}
.msg-portrait{
    flex: 8;
}
.head-portrait {
   margin-right: 15px;
   float: left;
}
.portrait-box{
    display: block;
    width: 70px;
    border-radius: 50%;
    line-height: 70px;
    text-align: center;
    overflow: hidden;
    margin-top: 5px;
    height: 70px;
}
.head-portrait img {
    width: 100%;
    border-radius: 50%;
    height: 100%;
}
.information-content {
    width: 150px;
    float: left;
}
.information-content ul {
    color: #333;
    width: 100%;
    line-height: 24px;
    font-size: 14px;
}
.information-compile {
    width: 41px;
    height: 21px;
    color: #fff;
    line-height: 21px;
    background-color: #FFD602;
    text-align: center;
    border-radius: 7%;
    flex: 2;
}
.write-wrapper {
    width: 100%;
    overflow-y: auto;
    position: fixed;
    top: 176px;
    bottom: 50px;
    background: #fff;
}
.education-details-wrapper {
    height: 100%;
    width: 100%;
}
.after-fill {
    height: 34px;
    width: 100%;
    text-align: center;
    float: left;
}

.after-fill span {
    line-height: 34px;
    text-align: center;
    font-size: 14px;
    color: #FFD602;
}
.positioning-wrapper {
    width: 100%;
    position: fixed;
    bottom: 0;
}
.submit-wrapper {
    height: 51px;
    background-color: #F0F0F0;
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.submit-wrapper .submit-btn{
    height: 35px;
    width: 225px;
    margin: 0 auto;
    background-color: #FFD602;
    border-radius: 5px;
    text-align: center;
    line-height: 35px;
    font-size: 15px;
    color: #FFF;
}
.number {
    width: 100%;
    padding: 0 100px;
    height: 206px;
    background-color: #fff;
    border-radius: 10px;
}
.foldS1{
    text-align: center;
    font-size: 16px;
}
.foldS2{
    color: #000;
    position: absolute;
    left: 10px;
    font-size: 16px;
}
.icon-add{
    color: #ffd602;
}
.icon-jianhao{
    color: #ffd602;
}
.slide{
    position: relative;
    background: #f2f2f2;
    padding: 0 15px;
    overflow: hidden;
    max-height: 0;
    color: #000;
    font-size: 12px;
    transition: max-height .5s cubic-bezier(0, 1, 0, 1) -.1s;
}
.slide-center{
    width: 100%;
    overflow: hidden;
    float: left;
    border-bottom: 1px #ffd602 dashed;
    padding: 10px 0;
    margin-top: 10px;
}
.slide-left{
    width: 80%;
    height: auto;
    line-height: 20px;
    float: left;
    text-align: left;
    padding-right: 5px;
}
.slide-left p{
    line-height: 20px;
}
.slide-right{
    float: right;
    overflow: hidden;
}
.slidebtn-right{
    height: 25px;
    width: 100%;
    line-height: 25px;
    text-align: center;
    float: right;
    color: #FFD602;
    /* background-color: #FFD602; */
    /* border-radius: 5px; */
    margin-bottom: 20px;
}
.slidebtn-right1{
    height: 25px;
    width: 100%;
    line-height: 25px;
    text-align: center;
    float: right;
    color: #FFD602;
    /* background-color: #FFD602; */
    /* border-radius: 5px; */
}
.animate{
    max-height: 9999px;
    transition-timing-function: cubic-bezier(0.5, 0, 1, 0);
    transition-delay: 0s;
    background: #fff;
}
#resume-box-list ul{
    width: 100%;
    height: 100%;
    margin-bottom: 20px;
}
#resume-box-list ul li{
    width: 100%;
    height: auto;
    line-height: 40px;
    text-align: center;
    font-size: 14px;
    color: #ffd602;
    border-bottom: 1px solid #dfdfdf;
}
.button{
    position: relative;
    right: 0;
    bottom: 30%;
    width: 20%;
}
.hrspan{
    display: block;
    width: 100%;
    height:1px;
    background: #000;
}
.Q-wrapper{
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 10px 0;
    margin-top: 10px;
}
.Q{
    text-align: left;
    overflow: hidden;
    margin-bottom: 10px;
}
.Q label{
    font-size: 14px;
    color: #333;
}
.radio-wrapper{
    width: 100%;
    margin: 10px 0;
}
</style>
